package com.shujia.flink.tf;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Demo7Union {
    public static void main(String[] args) throws Exception {
        //创建环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStream<String> lines1DS = env.socketTextStream("master", 8888);
        DataStream<String> lines2DS = env.socketTextStream("master", 9999);

        /*
         * union: 合并两个流，再数据层面没有合并，是再逻辑层面合并的
         * 相当于sql中的union all,
         * 两个DS的类型要一致
         */
        DataStream<String> unionDS = lines1DS.union(lines2DS);

        unionDS.print();

        env.execute();
    }
}
